<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			*{
				padding: 0;
				margin: 0;
			}
			#test{
				width: 100px;
				height: 30px;
				border: 3px solid #000;
			}
			#test:after{
				content: 'abc';
				color: red;
			}
		</style>
		
	</head>
	<body>
		<div id="test">
			这是div
		</div>
	</body>
	<script>
		function getStyle(obj,style) {  
		    if(obj.currentStyle) {  
		        return obj.currentStyle[style];  
		    } else {  
		        return getComputedStyle(obj)[style];  
		    }  
		}  
	    var demo = document.getElementById('test');  
	    console.log(getStyle(demo,'width'));  
	    console.log(getComputedStyle(demo,':after').color);  
	</script>
</html>